﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace AirDrive.Companion
{
    public partial class AboutForm : Form
    {
        private static AboutForm _openedForm;

        public AboutForm()
        {
            InitializeComponent();
            linkLabel.Links[0].LinkData = "https://www.microsoft.com/store/apps/9nblggh5x419";
        }

        private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start(e.Link.LinkData as string);
        }

        protected override void OnClosed(EventArgs e)
        {
            _openedForm = null;
            base.OnClosed(e);
        }

        public static void ShowForm()
        {
            if (_openedForm == null)
            {
                _openedForm = new AboutForm();
                
                using (Stream str = Assembly.GetExecutingAssembly().GetManifestResourceStream("AirDrive.Companion.Assets.AirDriveSmallLogo.ico"))
                {
                    _openedForm.Icon = new Icon(str);
                }

                using (Stream str = Assembly.GetExecutingAssembly().GetManifestResourceStream("AirDrive.Companion.Assets.AirDriveLogo.png"))
                {
                    _openedForm.pictureBox.Image = Bitmap.FromStream(str);
                }

                _openedForm.Show();
            }
            else
                _openedForm.Activate();
        }
    }
}
